import{g as w,a as A,s as I,_ as g,r as p,u as L,b as T,j as e,c as j,d as k,e as F,f as O,h as b,i as R,k as W,l as i,F as x,L as z,T as D,B as d,M as y,m as C,n as M,o as P,p as U,q}from"./index-aaf7dbcc.js";import{C as S,a as E,L as N,d as H}from"./Loading-ac930979.js";function $(t){return w("MuiCardActions",t)}A("MuiCardActions",["root","spacing"]);const G=["disableSpacing","className"],Q=t=>{const{classes:s,disableSpacing:o}=t;return k({root:["root",!o&&"spacing"]},$,s)},V=I("div",{name:"MuiCardActions",slot:"Root",overridesResolver:(t,s)=>{const{ownerState:o}=t;return[s.root,!o.disableSpacing&&s.spacing]}})(({ownerState:t})=>g({display:"flex",alignItems:"center",padding:8},!t.disableSpacing&&{"& > :not(:first-of-type)":{marginLeft:8}})),J=p.forwardRef(function(s,o){const n=L({props:s,name:"MuiCardActions"}),{disableSpacing:c=!1,className:u}=n,h=T(n,G),r=g({},n,{disableSpacing:c}),a=Q(r);return e(V,g({className:j(a.root,u),ownerState:r,ref:o},h))}),K=J,X=({board:t})=>{const{user:s}=F(f=>f.auth),[o,n]=p.useState(!1),c=()=>n(!0),u=()=>n(!1),[h,{}]=O(),{register:r,handleSubmit:a}=b(),m=f=>h({boardId:t.id,login:f.login}),[l,{}]=R(),B=()=>l({boardId:t.id}),[_,{}]=W(),v=()=>_({boardId:t.id});return i(x,{children:[i(S,{sx:{m:1,width:250,height:125},children:[e(E,{children:e(z,{to:`/board/${t.id}`,children:e(D,{variant:"h4",children:t.title})})}),e(K,{children:t.creator_id===s.id?i(x,{children:[e(d,{onClick:c,size:"small",children:"Добавить"}),e(d,{onClick:B,size:"small",children:"Удалить"})]}):e(d,{size:"small",onClick:v,children:"Покинуть"})})]}),e(y,{open:o,onClose:u,sx:{display:"flex",justifyContent:"center",mt:20},children:i(C,{component:"form",onSubmit:a(m),sx:{background:"white",width:300,maxHeight:200,display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",borderRadius:2,p:2},children:[e(M,{sx:{mb:2},required:!0,label:"Имя пользователя",autoFocus:!0,...r("login"),fullWidth:!0}),e(d,{type:"submit",fullWidth:!0,children:"Добавить"})]})})]})},Y=p.lazy(()=>P(()=>import("./Layout-ef000408.js"),["assets/Layout-ef000408.js","assets/index-aaf7dbcc.js"])),te=()=>{const[t,s]=p.useState(!1),o=()=>s(!0),n=()=>s(!1),[c,{}]=U(),{register:u,handleSubmit:h}=b(),r=l=>c({boardTitle:l.boardTitle}),{data:a,isLoading:m}=q(null);return i(Y,{children:[i(C,{sx:{display:"flex",flexWrap:"wrap"},children:[m?e(N,{}):a==null?void 0:a.map(l=>e(X,{board:l},l.id)),e(S,{sx:{m:1,width:250,display:"flex",justifyContent:"center",alignItems:"center",height:125},children:e(d,{sx:{height:"100%",width:"100%"},onClick:o,children:e(H,{fontSize:"large"})})})]}),e(y,{open:t,onClose:n,sx:{display:"flex",justifyContent:"center",mt:20},children:i(C,{component:"form",onSubmit:h(r),sx:{background:"white",width:300,maxHeight:200,display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",borderRadius:2,p:2},children:[e(M,{sx:{mb:2},required:!0,label:"Название доски",autoFocus:!0,...u("boardTitle"),fullWidth:!0}),e(d,{variant:"outlined",type:"submit",fullWidth:!0,children:"Подтвердить"})]})})]})};export{te as default};
